"""
输出全排列
"""
import random
def f(n):
    p = 1
    for i in range(1, n+1):
        p *= i
    return p
n = eval(input())
list1 = [str(i) for i in range(1, n+1)]
s = set()
maxC = f(n)
while len(s) < maxC:
    random.shuffle(list1)
    s.add("".join(list1))
s = sorted(s)
for i in s:
    print(i)

